/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dk.rofl.items;

import java.awt.Color;
import rofl.Utils;

/**
 *
 * @author Jeppe
 */
public abstract class Equipment extends GameItem {

    // Equipment quality.
    public static final int QUALITY_CRUDE = 0;
    public static final int QUALITY_NORMAL = 1;
    public static final int QUALITY_MAGIC = 2;
    public static final int QUALITY_SUPERIOR = 3;
    public static final int QUALITY_EPIC = 4;
    private int itemQuality;
    private int staminaBonus;
    private int strengthBonus;

    public Equipment(int itemType, String itemName, int itemLevel, int itemQuality) {
        super(itemType, itemName, itemLevel);
        this.itemQuality = itemQuality;
        staminaBonus = 0;
        strengthBonus = 0;
    }

    public void setStaminaBonus(int value) {
        staminaBonus = value;
    }

    public int getStaminaBonus() {
        return staminaBonus;
    }

    public void setStrengthBonus(int value) {
        strengthBonus = value;
    }

    public int getStrengthBonus() {
        return strengthBonus;
    }

    public int getItemQuality() {
        return itemQuality;
    }

    public static Color getItemQualityColor(int itemQuality) {
        Color c = null;
        switch (itemQuality) {
            case Equipment.QUALITY_CRUDE:
                c = new Color(127, 127, 127);
                break;
            case Equipment.QUALITY_NORMAL:
                c = new Color(255, 255, 255);
                break;
            case Equipment.QUALITY_MAGIC:
                c = new Color(63, 255, 63);
                break;
            case Equipment.QUALITY_SUPERIOR:
                c = new Color(63, 63, 255);
                break;
            case Equipment.QUALITY_EPIC:
                c = new Color(255, 63, 255);
                break;
        }
        return c;
    }

    public static int generateItemQuality() {
        int quality = 0;

        int r = Utils.rnd().nextInt(100);
        if (r < 39) {
            quality = Equipment.QUALITY_CRUDE;
        }
        if (r >= 39 && r < 79) {
            quality = Equipment.QUALITY_NORMAL;
        }
        if (r >= 79 && r < 94) {
            quality = Equipment.QUALITY_MAGIC;
        }
        if (r >= 94 && r < 99) {
            quality = Equipment.QUALITY_SUPERIOR;
        }
        if (r == 99) {
            quality = Equipment.QUALITY_EPIC;
        }
        return quality;
    }

    public static String generatePrefix(int itemQuality) {
        String s = "";
        switch (itemQuality) {
            case Equipment.QUALITY_CRUDE:
                s = "Crude ";
                break;
            case Equipment.QUALITY_NORMAL:
                s = "";
                break;
            case Equipment.QUALITY_MAGIC:
                s = "Superior ";
                break;
            case Equipment.QUALITY_SUPERIOR:
            case Equipment.QUALITY_EPIC:
                int r = Utils.rnd().nextInt(5);
                switch (r) {
                    case 0:
                        s = "Unstoppable ";
                        break;
                    case 1:
                        s = "Unbreakable ";
                        break;
                    case 2:
                        s = "Raging ";
                        break;
                    case 3:
                        s = "Glowing ";
                        break;
                    case 4:
                        s = "Cursed ";
                        break;
                }
        }
        return s;
    }

    public static String generatePostfix(int itemQuality) {
        String s = "";
        switch (itemQuality) {
            case Equipment.QUALITY_CRUDE:
                s = "";
                break;
            case Equipment.QUALITY_NORMAL:
                s = "";
                break;
            case Equipment.QUALITY_MAGIC:
                s = "";
                break;
            case Equipment.QUALITY_SUPERIOR:
                s = "";
                break;
            case Equipment.QUALITY_EPIC:
                int r = Utils.rnd().nextInt(7);
                switch (r) {
                    case 0:
                        s = " of Doom";
                        break;
                    case 1:
                        s = " of Power";
                        break;
                    case 2:
                        s = " of Rage";
                        break;
                    case 3:
                        s = " of Fury";
                        break;
                    case 4:
                        s = " of Darkness";
                        break;
                    case 5:
                        s = " of Light";
                        break;
                    case 6:
                        s = " of the Lords";
                        break;
                }
                break;
        }
        return s;
    }
}
